package com.itbaizhan.rediswebdemo.conntory;

import com.itbaizhan.rediswebdemo.entity.GoodsEntity;
import com.itbaizhan.rediswebdemo.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/*商品的控制层,调用业务层*/
@RestController
@RequestMapping("/goods")
public class GoodsController {

    @Autowired
    private GoodsService goodsService;

    /*根据id查询商品信息*/
    @GetMapping("/getbyid")
    public GoodsEntity getById(String id){
        return goodsService.getById(Long.valueOf(id));//String转为Long
    }
}
/*测试地址：localhost:8080/goods/getbyid?id=1*/